package com.example.demo.pattern.chainofresponsibility;

public class ChainPatternDemo {
    private static AbstractLogger getChainOfLogger(){
        WarnLogger warnLogger = new WarnLogger(AbstractLogger.WARN);
        InfoLogger infoLogger = new InfoLogger(AbstractLogger.INFO);
        DebugLogger debugLogger = new DebugLogger(AbstractLogger.DEBUG);
        warnLogger.setNextLogger(infoLogger);
        infoLogger.setNextLogger(debugLogger);
        return warnLogger;
    }

    public static void main(String[] args) {
        AbstractLogger loggerChain = getChainOfLogger();
        loggerChain.logMessage(AbstractLogger.WARN,"this is an warn message");
        loggerChain.logMessage(AbstractLogger.INFO,"this is an info message");
        loggerChain.logMessage(AbstractLogger.DEBUG,"this is an debug message");
    }
}
